package flyweight;

public class Client {
    public static void main(String[] args) {
        FlyweightFactory flyweightFactory = new FlyweightFactory();
        FlyweightFactory.show();

        Flyweight flyweight = flyweightFactory.getFlyweight("共享对象1");
        FlyweightFactory.show();
        flyweight.operate();

        flyweight = flyweightFactory.getFlyweight("共享对象2");
        FlyweightFactory.show();
        flyweight.operate();

        flyweight = flyweightFactory.getFlyweight("共享对象1");
        FlyweightFactory.show();
        flyweight.operate();

        String str1 = "abc";
        String str2 = "abc";
        String str3 = new String("abc");
        String str4 = new String("abc");
        System.out.println(str1 == str2); // true
        System.out.println(str3 == str4); // false
    }
}
